package net.service.Impl;

import net.mapper.ArtileMapper;
import net.pojo.Artile;
import net.pojo.Dicuss;
import net.service.ArtileService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;


import java.util.List;

/**
 * @Author admin
 * @Date 2019/5/22 10:23
 */
@Service
@Transactional
public class ArtileServiceImpl implements ArtileService {
   @Autowired
    ArtileMapper artileMapper;

    @Override
    public List<Artile> findAll() {
        return artileMapper.findAll();
    }

    @Override
    public List<Artile> findByTags(String tags) {
        return artileMapper.findByTags(tags);
    }

    @Override
    public List<Artile> findByComment() {
        return artileMapper.findByComment();
    }

    @Override
    public Artile findById(Integer pid) {
        return artileMapper.findById(pid);
    }

    @Override
    public List<Artile> findByClick() {
        return artileMapper.findByClick();
    }

    @Override
    public List<Artile> search(String title) {
        return artileMapper.search(title);
    }

    @Override
    public int updateClick(Artile artile) {
        artile.setClick(artile.getClick()+1);
        return artileMapper.updateClick(artile);
    }

    @Override
    public Artile findByIdPrev(Integer pid) {
        return artileMapper.findByIdPrev(pid);
    }

    @Override
    public Artile findByIdNext(Integer pid) {
        return artileMapper.findByIdNext(pid);
    }

    @Override
    public int updateComment(Artile artile) {
        artile.setComment(artile.getComment()+1);
        return artileMapper.updateComment(artile);
    }

    @Override
    public List<Dicuss> findAllByDpid(Integer dpid) {
        return artileMapper.findAllByDpid(dpid);
    }

    @Override
    public int insertDicuss(Dicuss dicuss) {
        return artileMapper.insertDicuss(dicuss);
    }

    @Override
    public List<Artile> findThreeByTags(String tags) {
        return artileMapper.findThreeByTags(tags);
    }
}
